<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class AccountResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id'         => (int)$this->id,
            'key'        => (string)$this->key,
            'name'       => (string)$this->name,
            'type'       => (string)$this->type,
            'token'      => (string)$this->token,
            'enable'     => (boolean)$this->enable,
            'created_at' => $this->created_at ? $this->created_at->toDateTimeString() : null,
            'updated_at' => $this->created_at ? $this->updated_at->toDateTimeString() : null,
        ];
    }
}
